from server import *
from settings import *
from common import *
from dispatcher import Dispatcher
from pathplanning import Path
from controller import Controller
from uppercomputer import VirtualWharf

from test import Case1

def set_up_modules():
    '''
    注册路径规划和车辆调度模块
    '''
    path_planner = Path(config_path)
    aiv_dispatcher = Dispatcher(path_planner, config_dispatcher)

    g_controller = Controller(config_sensor)
    g_controller.register_components(aiv_dispatcher)

    return g_controller

if __name__ == '__main__':
    # 初始化全局感知模块
    g_controller = set_up_modules()
    
    # 初始化虚拟码头
    upper = VirtualWharf(config_upper)
    upper.initialize(Case1.aivs, Case1.tasks)
    g_controller.setup_upper(upper)

    server = Server(config_server)
    server.setup_controller(g_controller)
    server.setup_virtual_uppercomputer(upper)
    
    server.run()